package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Customer;
import cn.wolfcode.crm.domain.CustomerTraceHistory;
import cn.wolfcode.crm.mapper.CustomerTraceHistoryMapper;
import cn.wolfcode.crm.query.CustomerTraceHistoryQueryObject;
import cn.wolfcode.crm.service.ICustomerTraceHistoryService;
import cn.wolfcode.crm.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerTraceHistoryServiceImpl implements ICustomerTraceHistoryService {

	@Autowired
	private CustomerTraceHistoryMapper customerTraceHistoryMapper;
	@Override
	public void deleteByPrimaryKey(Long id) {

		customerTraceHistoryMapper.deleteByPrimaryKey(id);
	}

	@Override
	public void insert(CustomerTraceHistory entity) {
		entity.setInputUser(UserContext.getCurrentUser());

		customerTraceHistoryMapper.insert(entity);
	}

	@Override
	public CustomerTraceHistory selectByPrimaryKey(Long id) {

		return customerTraceHistoryMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<CustomerTraceHistory> selectAll() {

		return customerTraceHistoryMapper.selectAll();
	}

	@Override
	public void updateByPrimaryKey(CustomerTraceHistory entity) {

		customerTraceHistoryMapper.updateByPrimaryKey(entity);
	}

	@Override
	public PageInfo query(CustomerTraceHistoryQueryObject qo) {
		//查询总记录数

		PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
		List<Customer> data = customerTraceHistoryMapper.queryForList(qo);
		return new PageInfo<Customer>(data);
	}

}
